package Base;

public class Reader {
    /*
    * 编写一个读者类,包括读者编号、姓名、密码、账户余额等成员域,要求编号流水自增长(假设初始编号为 10001);默认密码为“666666”,密码可以修改:默认姓名为空:默认余额为0,可以为账户充值,账户余额可以查看。
    *  readerID,readerName,readerPwd,blance,nextReaderID,note
    * */
    protected int readerID;
    protected String readerName;
    protected String readerPwd;
    protected double balance;
    protected String note; // 读者备注
    protected static int nextReaderID = 10001;

    public Reader() {}

    public Reader(String readerName) {
        this.readerName = readerName;
        this.readerID = nextReaderID;
        nextReaderID++;
        this.balance = 0;
        this.readerPwd = "666666";
    }

    @Override
    public String toString() {
        return "Base.Reader{" +
                "readerID=" + readerID +
                ", readerName='" + readerName + '\'' +
                ", readerPwd='" + readerPwd + '\'' +
                ", blance=" + balance +
                ", note='" + note + '\'' +
                '}';
    }

    public int getReaderID() {
        return readerID;
    }

    public void setReaderID(int readerID) {
        this.readerID = readerID;
    }

    public String getReaderName() {
        return readerName;
    }

    public void setReaderName(String readerName) {
        this.readerName = readerName;
    }

    public String getReaderPwd() {
        return readerPwd;
    }

    public void setReaderPwd(String readerPwd) {
        this.readerPwd = readerPwd;
        System.out.println("密码修改成功");
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        //  负数出错，提示，还是原本余额
        if (balance < 0) {
            this.note = "充值失败，余额不能为负数";
            return;
        }
        this.note = "充值成功";
        this.balance = balance;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public static int getNextReaderID() {
        return nextReaderID;
    }

    public static void setNextReaderID(int nextReaderID) {
        Reader.nextReaderID = nextReaderID;
    }

}
